package com.gangan.controller.web;


import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gangan.controller.common.BaseController;
import com.gangan.model.Dict;
import com.gangan.model.DictCate;
import com.gangan.service.IDictService;
import com.gangan.tools.MessageBean;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author jobob
 * @since 2019-09-04
 */
@Api(description = "*字典数据模块控制层")
@RestController
@RequestMapping("/dict")
public class DictController extends BaseController {

    @Autowired
    IDictService dictService;

    @RequestMapping(value = "/del",method = RequestMethod.POST)
    @ApiOperation(value="移除字典值", notes="根据自增主键移除数据")
    public MessageBean del(Integer id){
        return resultSuccess(dictService.removeById(id));
    }

    @RequestMapping(value = "/add",method = RequestMethod.POST)
    @ApiOperation(value="新增字典值", notes="将提交的数据保存到数据库")
    public MessageBean add(Dict add){
        return resultSuccess(dictService.save(add));
    }

    @RequestMapping(value = "/edit",method = RequestMethod.POST)
    @ApiOperation(value="编辑字典值", notes="根据主键修改数据")
    public MessageBean edit(Dict edit){
        return resultSuccess(dictService.updateById(edit));
    }
}
